<%--
  Created by IntelliJ IDEA.
  User: 1
  Date: 2023-3-6
  Time: 7:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/status/js/jquery.js"></script>
</head>
<body>
    <script>
        $(function () {
            $.getJSON("${pageContext.request.contextPath}/user/xlklist",function (data) {
                var xlid = $("#xlid").val();
                $("#bid").html("");
                var str = "<option value=\"0\">请选择</option>";
                for(var i = 0;i<data.length;i++){
                    if(data[i].id==xlid){
                        str+="<option value=\""+data[i].id+"\" selected>"+data[i].bmname+"</option>";
                    }else {
                        str+="<option value=\""+data[i].id+"\">"+data[i].bmname+"</option>";
                    }
                }
                $("#bid").append(str);
            })
        })
        function fanye(fm,fq) {
            fm.pageNo.value = fq;
            fm.submit();
        }
        function add() {
            location.href = "${pageContext.request.contextPath}/user/add";
        }
        function update(id) {
            location.href = "${pageContext.request.contextPath}/user/update?id="+id;
        }
        function del(id){
            var tt = confirm("是否删除");
            if(tt){
                location.href = "${pageContext.request.contextPath}/user/delete?id="+id;
            }
        }
    </script>
    <form>
        账号：<input type="text" name="account" value="${account}">姓名：<input type="text" name="realname" value="${realname}">
        <input type="hidden" name="pageNo" id="pageNo">
        <input type="hidden" name="xlid" id="xlid" value="${xlid}">
        所属部门:<select name="bid" id="bid">
                    <option value="0">请选择</option>
                </select>
        <input type="submit" value="查询"><input type="button" value="新增" onclick="add()">
        <table>
            <tr>
                <td>账号</td>
                <td>姓名</td>
                <td>性别</td>
                <td>头像</td>
                <td>身份证正面</td>
                <td>身份证反面</td>
                <td>生日</td>
                <td>手机号</td>
                <td>所在部门</td>
                <td>技能</td>
                <td>操作</td>
            </tr>
            <c:forEach items="${page.list}" var="i">
                <tr>
                    <td>${i.account}</td>
                    <td>${i.realname}</td>
                    <td><c:if test="${i.sex==1}">男</c:if><c:if test="${i.sex==0}">女</c:if></td>
                    <td><img src="http://localhost:8080/img/${i.img}" width="50px"></td>
                    <td><img src="http://localhost:8080/img/${i.idcardzm}" width="50px"></td>
                    <td><img src="http://localhost:8080/img/${i.idcardbm}" width="50px"></td>
                    <td><fmt:formatDate value="${i.birthday}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                    <td>${i.phone}</td>
                    <td>${i.bmname}</td>
                    <td><c:forEach items="${i.list}" var="t">${t}</c:forEach> </td>
                    <td><a href="#" onclick="del(${i.id})">删除</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="update(${i.id})">修改</a>&nbsp;&nbsp;<a href="${pageContext.request.contextPath}/user/shangchuan?id=${i.id}">上传身份证照片</a></td>
                </tr>
            </c:forEach>
        </table>
        <c:if test="${page.pageNo==1}">
            <a href="javascript:void(0)">首页</a>
        </c:if>
        <c:if test="${page.pageNo>1}">
            <a href="javascript:fanye(document.forms[0],1)">首页</a>
        </c:if>
        <c:if test="${page.pageNo>1}">
            <a href="javascript:fanye(document.forms[0],${page.pageNo-1})"><<</a>
        </c:if>
        <c:forEach end="${page.pageSum}" begin="1" var="f">
            <a href="javascript:fanye(document.forms[0],${f})">${f}</a>
        </c:forEach>
        <c:if test="${page.pageNo<page.pageSum}">
            <a href="javascript:fanye(document.forms[0],${page.pageNo+1})"> >> </a>
        </c:if>
        <c:if test="${page.pageNo<page.pageSum}">
            <a href="javascript:fanye(document.forms[0],${page.pageSum})">尾页</a>
        </c:if>
        <c:if test="${page.pageNo==page.pageSum}">
            <a href="javascript:void(0)">尾页</a>
        </c:if>
    </form>
</body>
</html>
